program chapter6_7
    implicit none

    character line*80, a
    integer i,sym,j,num,n
    print *,'input rows=?'
    read*, n
    num=0
    do i=1,n
        read *, line !read line no.i
        sym=0

        do j=1,80 !from first letter to the last one
            a=line(j:j)
            if (a .eq. ' ' .or. a .eq. ',' .or. a .eq. '.' .or. j .eq. 80 .or. a .eq. '?') then
                if (sym .eq. 1) then
                    num=num+1
                    sym=0
                end if
            else
                sym=1
            end if
        !print *,sym,num,j
        end do
        !print *, num
    end do

    print *, 'words=',num

end program

